package com.hl.sfzy.controller;

import com.hl.sfzy.entity.LogonUser;
import com.hl.sfzy.service.LogonUserService;
import com.hl.sfzy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: sfzy
 * @description: 孙源源-用户登录
 * @author: Syy
 * @create: 2024-09-05 17:59
 **/
@RestController
@RequestMapping("/user")
public class LogonUserController {
    @Autowired
    private LogonUserService logonUserService;

    @GetMapping("/logon")
    public R logon(String identifier, String password) {
        LogonUser user = logonUserService.logon(identifier, password);
        if (user != null) {
            // 登录成功，返回用户信息
            return R.success(user);
        } else {
            // 登录失败
            return R.failure("登录失败，用户名或密码错误");
        }
    }
}
